package edu.itstudy.services.impl;

import java.util.List;

import edu.itstudy.bean.User;
import edu.itstudy.dao.IUserDao;
import edu.itstudy.dao.imp.IUserDaoImp;
import edu.itstudy.services.IUserServices;

public class IUserServicesImpl implements IUserServices {
	
	private IUserDao iuserDao = new IUserDaoImp();
	public boolean register(User user) {
		//根据数据处理结果来决定业务逻辑结果
		int i = iuserDao.register(user);
		return i>0?true:false;
	}
	public boolean login(User user) {		
		int uid = iuserDao.login(user);	
		return  uid>0?true:false;
	}
	public List<User> getIndexUser(){
		List<User> list = iuserDao.getIndexUser();
		if(null==list ||list.size()==0) {
			return null;
		}
		return list;
	}
	public List<User> getAllUser(User user){
		List<User> list = iuserDao.getAllUser(user);
		if(null == list ||list.size() == 0) {
			return null;
		}
		return list;
	}

	public User getUserById(int uid) {
		User user  = iuserDao.getUserById(uid);
		return user;
	}
	public boolean updateUser(User user) {
		int i = iuserDao.updateUser(user);
		return i>0?true:false;
	}
	public boolean deleteUserById(int uid) {
		int i = iuserDao.deleteUserById(uid);
		return i>0?true:false;
	}
	public boolean updateUserById(int uid,int flag) {
		int i = iuserDao.updateUserById(uid, flag);
		return i>0?true:false;

	}
}
